package com.lucas.springboot_restful_api.core;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Builder;
import lombok.ToString;
import org.springframework.stereotype.Component;

import java.io.Serializable;

@ToString
@Builder
@Component
public class UnifyResponse implements Serializable {

    @JSONField(ordinal = 1)
    private int err_code;
    @JSONField(ordinal = 2)
    private String err_msg;
    @JSONField(ordinal = 3)
    private String request;
    @JSONField(ordinal = 4)
    private Object data;

    public UnifyResponse() {
        this.err_code = 200;
        this.err_msg = "ok";
    }

    public UnifyResponse(String err_msg) {
        this.err_code = 200;
        this.err_msg = err_msg;
    }

    public UnifyResponse(String err_msg,Object data) {
        this.err_code = 200;
        this.err_msg = err_msg;
        this.data = data;
    }

    public UnifyResponse(int err_code, String err_msg) {
        this.err_code = err_code;
        this.err_msg = err_msg;
    }

    public UnifyResponse(int err_code, String err_msg, Object data) {
        this.err_code = err_code;
        this.err_msg = err_msg;
        this.data = data;
    }

    public UnifyResponse(int err_code, String err_msg, String request) {
        this.err_code = err_code;
        this.err_msg = err_msg;
        this.request = request;
    }

    public UnifyResponse(int err_code, String err_msg, String request, Object data) {
        this.err_code = err_code;
        this.err_msg = err_msg;
        this.request = request;
        this.data = data;
    }

    public int getErr_code() {
        return err_code;
    }

    public void setErr_code(int err_code) {
        this.err_code = err_code;
    }

    public String getErr_msg() {
        return err_msg;
    }

    public void setErr_msg(String err_msg) {
        this.err_msg = err_msg;
    }

    public String getRequest() {
        return request;
    }

    public void setRequest(String request) {
        this.request = request;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
